#define _CRT_SECURE_NO_WARNINGS
#include<stdlib.h>
#include<stdio.h>
#include<string.h>

int main()
{
	FILE* fp = fopen("test.txt","w");
	if (fp == NULL)
	{
		perror("file open error");
		return -1;
	}
	while (1)
	{
		char buf[100];
		char * ch = fgets(buf, 100, stdin);
		if (strcmp(ch,":wq\n") == 0)
		{
			break;
		}
		fputs(buf,fp);

	}

	fclose(fp);
	system("pause");
	return EXIT_SUCCESS;
}
